package com.iterator.bean.wechat.order.vo;

import com.iterator.bean.wechat.order.OrderStatusEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.List;

/**
 * @Author : L
 * @ProjectName : project-2
 * @Date : 1/12/2021
 * @Description :
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class OrderListDataVO {

    /**
     * orderStatusText : 已收货
     * isGroupin : false
     * orderSn : 20200427674885
     * actualPrice : 2599
     * goodsList : [{"number":1,"picUrl":"http://yanxuan.nosdn.127.net/45548f26cfd0c7c41e0afc3709d48286.png","id":2,"goodsName":"宫廷奢华真丝四件套"}]
     * id : 2
     * handleOption : {"cancel":false,"delete":true,"pay":false,"comment":true,"confirm":false,"refund":false,"rebuy":true}
     */

    private String orderStatusText;
    private boolean isGroupin;
    private String orderSn;
    private BigDecimal actualPrice;
    private int id;
    private HandleOptionBeanVO handleOption = new HandleOptionBeanVO();
    private List<GoodsListBeanVO> goodsList;

    public void setIsGroupin(boolean b) {
        this.isGroupin = b;
    }

    public void setOrderStatusText(Short orderStatus) {
        if (orderStatus == 101) {
            orderStatusText = OrderStatusEnum.UN_PAID.getStatusText();
//            handleOption.setCancel(true);
//            handleOption.setDelete(true);
//            handleOption.setPay(true);
        } else if (orderStatus == 102) {
            orderStatusText = OrderStatusEnum.USER_CANCELED.getStatusText();
//            handleOption.setDelete(true);
        } else if (orderStatus == 103) {
            orderStatusText = OrderStatusEnum.SYSTEM_CANCELED.getStatusText();
//            handleOption.setDelete(true);
        } else if (orderStatus == 201) {
            orderStatusText = OrderStatusEnum.PAID.getStatusText();
//            handleOption.setRefund(true);
        } else if (orderStatus == 202) {
            orderStatusText = OrderStatusEnum.REFUND_REQUESTED.getStatusText();
        } else if (orderStatus == 203) {
            orderStatusText = OrderStatusEnum.REFUNDED.getStatusText();
        } else if (orderStatus == 301) {
            orderStatusText = OrderStatusEnum.SHIPPED.getStatusText();
//            handleOption.setConfirm(true);
        } else if (orderStatus == 401) {
            orderStatusText = OrderStatusEnum.USER_RECEIPTED.getStatusText();
//            handleOption.setDelete(true);
//            handleOption.setComment(true);
//            handleOption.setRebuy(true);
        } else if (orderStatus == 402) {
            orderStatusText = OrderStatusEnum.SYSTEM_RECEIPTED.getStatusText();
//            handleOption.setDelete(true);
//            handleOption.setComment(true);
//            handleOption.setRebuy(true);
        }
    }

    public void setHandleOption(Short orderStatus) {
        if (orderStatus == 101) {
            handleOption.setCancel(true);
            handleOption.setDelete(true);
            handleOption.setPay(true);
        } else if (orderStatus == 102) {
            handleOption.setDelete(true);
        } else if (orderStatus == 103) {
            handleOption.setDelete(true);
        } else if (orderStatus == 201) {
            handleOption.setRefund(true);
        }
//        else if (orderStatus == 202) {
//        } else if (orderStatus == 203) {
//        }
        else if (orderStatus == 301) {
            handleOption.setConfirm(true);
        } else if (orderStatus == 401) {
            handleOption.setDelete(true);
            handleOption.setComment(true);
            handleOption.setRebuy(true);
        } else if (orderStatus == 402) {
            handleOption.setDelete(true);
            handleOption.setComment(true);
            handleOption.setRebuy(true);
        }
    }
}
